<?php

namespace App\Models;

class UserReadLog extends Base
{
    public $timestamps = false;

    public function __construct(array $attributes = [])
    {
        if (isset($attributes['user_id'])) {
            $suffixes = calc_hash_db($attributes['user_id'], 10);
            $this->table = 'user_read_logs_' . $suffixes;
        }
        parent::__construct($attributes);
    }

//    public function switch($user_id) {
//        $suffixes = calc_hash_db($user_id, 10);
//        $this->table = 'user_read_logs_' . $suffixes;
//    }

    public function create($input) {
//        $this->switch($input['user_id']);
        return parent::create($input);
    }

    public function article() {
        return $this->belongsTo(Article::class, 'article_id');
    }

}
